#include<bits/stdc++.h>

using namespace std;

int n;
bool f[200007],visit[200007];

int main()
{
	freopen("fruit.in","r",stdin);
	freopen("fruit.out","w",stdout);
	cin>>n;
	for(int i=1;i<=n;i++){
		cin>>f[i];
	}
	int cnt=0;
	while(cnt<n){
		int i=1;
		while(visit[i]){
			i++;
		}
		visit[i] = 1;
		printf("%d ",i);
		cnt++;
		bool k=f[i];
		for(i++;i<=n;i++){
			if(!visit[i]&&f[i]!=k){
				k = !k;
				printf("%d ",i);
				visit[i] = 1;
				cnt++;
			}
		}
		printf("\n");
	}
	return 0;
}
